﻿using System;
using System.Linq;
using Windows.UI.Xaml.Data;

namespace Wala.Infrastructure.Converters
{
    public sealed class AvatarIdToLinkConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            long avatarId;
            string avatarLink = string.Empty;

            if (long.TryParse(value.ToString(), out avatarId))
            {
                if (avatarId != 0)
                {
                    avatarLink = string.Format(URLConstant.GET_AVATAR, avatarId);
                }
                else
                {
                    avatarLink = "ms-appx:///Assets/Login/icon_logo.png";
                }
            }
            return avatarLink;
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            // TODO: Implement this method
            throw new NotImplementedException();
        }
    }
}
